package DomainObject;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;

import org.omg.PortableServer.POA;

import Combat5.Server;
import ca.etsmtl.log720.lab1.CollectionDossierPOA;
import ca.etsmtl.log720.lab1.Dossier;
import ca.etsmtl.log720.lab1.DossierHelper;
//create by martin souliere
public class CollectionDossierImpl extends CollectionDossierPOA implements Serializable{

	private ArrayList<DossierImpl> _dossiers;
	public CollectionDossierImpl(ArrayList<DossierImpl> dossiers){
		_dossiers = dossiers;
	}
	public CollectionDossierImpl(){
		_dossiers = new ArrayList<DossierImpl>();
	}
	public Dossier getDossier(int index) {
		try {
			// Trouver le dossier correspondant au parametre "index"
			DossierImpl dossier = _dossiers.get(index);

			// REcuperer le POA cree dans le serveur
			POA rootpoa = Server._poa;

			// Activer l'objet et retourner l'objet CORBA
			org.omg.CORBA.Object obj = rootpoa.servant_to_reference(dossier);

			// Retourner un dossier
			return DossierHelper.narrow(obj);
		} catch (Exception e) {
			return null;
		}
	}

	public int size() {
		return _dossiers.size();
	}
	public ArrayList<DossierImpl> getListeDossiers() {
		return _dossiers;
	}
}
